package com.example.yian.config;

import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate;

import java.util.ArrayList;
import java.util.List;

public class RestTemplateConfig {

    public static RestTemplate restTemplate() {
        RestTemplate restTemplate = new RestTemplate();
        List<HttpMessageConverter<?>> messageConverters = new ArrayList<>();

        // 添加默认的消息转换器
        messageConverters.add(new MappingJackson2HttpMessageConverter());


        restTemplate.setMessageConverters(messageConverters);
        return restTemplate;
    }
}
